package com.qingzhou.log.aspect;

import com.qingzhou.log.pojo.SysLog;
import com.qingzhou.log.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;


/**
 * @author huoming
 * 切面注册器
 * */
@Component
public class AspectRegistry {
    private List<BaseLogAspect> baseLogAspects=new ArrayList<BaseLogAspect>();

    private SysLog sysLog;

    @Autowired
    private SysLogService sysLogService;

    public void writeLog(){
        sysLogService.writeLog(sysLog);
    }

    public void updateSysLog(BaseLogAspect baseLogAspect,SysLog sysLog){
        this.sysLog=sysLog;
        if (baseLogAspect==baseLogAspects.get(0)){
            writeLog();
        }
    }

    public void register(BaseLogAspect baseLogAspect){
        baseLogAspects.add(baseLogAspect);
    }
}
